package com.learningpattern.factory.simplefactory;

import com.learningpattern.factory.CSGame;
import com.learningpattern.factory.DOTAGame;
import com.learningpattern.factory.IGame;
import com.learningpattern.factory.LOLGame;

public class GameFactory {

  /*  public  IGame create(String game){
        if (game.equals("CS")){
            return new CSGame();
        }else if(game.equals("LOL")){
            return new LOLGame();
        }else if(game.equals("DOTA")){
            return new DOTAGame();
        }else{
            return null;
        }

    }*/
  /*public IGame create(String classname){
    try {
        if(!(null==classname||"".equals(classname))){
           return  (IGame)Class.forName(classname).newInstance();
        }
    }catch (Exception e){
        e.printStackTrace();
    }
    return null;
  }*/
  public IGame create(Class clazz){
      try {
          if(null!=clazz){
              return  (IGame)clazz.newInstance();
          }
      }catch (Exception e){
          e.printStackTrace();
      }
      return null;
  }
}
